package com.easy.controller;

import com.easy.bean.Bookshelf;
import com.easy.service.BookshelfService;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("bookshelf")
public class BookshelfController {

    @Autowired
    BookshelfService bookshelfService;

    @PostMapping
    public Result add(@RequestBody Bookshelf bookshelf){
        Object obj=bookshelfService.add(bookshelf);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Bookshelf bookshelf){
        Object obj=bookshelfService.edit(bookshelf);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj= bookshelfService.del(id);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=bookshelfService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Bookshelf bookshelf){
        Object obj=bookshelfService.all(bookshelf);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(com.easy.util.Page page,Bookshelf bookshelf){
        bookshelfService.page(page,bookshelf);
        return Result.success(page);
    }
}

